package sebastiankerckhof.scene;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

import sebastiankerckhof.render.raytrace.Hit;
import sebastiankerckhof.render.raytrace.Ray;
import sebastiankerckhof.scene.lighting.PointLight;
import sebastiankerckhof.scene.material.DiffuseMaterial;
import sebastiankerckhof.structure.Color3f;
import sebastiankerckhof.structure.Triangle;

public class Scene{

	public List<Surface> surfaces = new ArrayList<Surface>();
	public PointLight light;
	public DiffuseMaterial material;
	public Camera camera;
	public Color3f backgroundColor;
	
	public Color3f getBackgroundColor(){
		return this.backgroundColor;
	}
	
	public void setBackgroundColor(Color3f color){
		this.backgroundColor = color;
	}
	
	
	public List<Triangle> getTriangles(){
		List<Triangle> triangles = new LinkedList<Triangle>();
		for(Surface h : surfaces){
			Mesh m = (Mesh) h;
			triangles.addAll(Arrays.asList(m.triangles));
		}
		return triangles;
	}


  public Hit intersect(Ray r, float t0, Hit hr) {
	  for(Triangle t : getTriangles()){
      t.intersect(r,t0, hr);
	  }
	  
	  return hr;
  }


}
